from sqlalchemy import Column, INTEGER, DATETIME
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_dm import VARCHAR2, DATE, NUMBER

Base = declarative_base()

class RiskHistoryTemp(Base):
    # 模式名
    __table_args__ = {'schema': 'ESUNTEST'}
    # 表名
    __tablename__ = 'HX_BI_HSH_TEMP'

    PCH = Column(VARCHAR2(100))
    CREATOR = Column(VARCHAR2(20))
    CREATE_TIME = Column(DATETIME)
    ID = Column(INTEGER, primary_key=True)
    CODE = Column(VARCHAR2(20))
    FXBGPC = Column(VARCHAR2(100))
    TGSJ = Column(VARCHAR2(20))
    SSEJ = Column(VARCHAR2(20))
    CYDW = Column(VARCHAR2(255))
    JYDS = Column(VARCHAR2(255))
    SXLX = Column(VARCHAR2(100))
    JYLX = Column(VARCHAR2(20))
    JYBS = Column(NUMBER)
    JYJE = Column(NUMBER(10, 2))
    FKQK = Column(VARCHAR2(1024))
    MZQK = Column(VARCHAR2(255))

    @classmethod
    def from_dict(cls, data):
        return cls(
            PCH=data['PCH'],
            CREATOR=data['CREATOR'],
            CREATE_TIME=data['CREATE_TIME'],
            ID=data['ID'],
            CODE=data['CODE'],
            FXBGPC=data['FXBGPC'],
            TGSJ=data['TGSJ'],
            SSEJ=data['SSEJ'],
            CYDW=data['CYDW'],
            JYDS=data['JYDS'],
            SXLX=data['SXLX'],
            JYLX=data['JYLX'],
            JYBS=data['JYBS'],
            JYJE=data['JYJE'],
            FKQK=data['FKQK'],
            MZQK=data['MZQK']
        )

    def to_dict(self):
        return {
            'PCH': self.PCH,
            'CREATOR': self.CREATOR,
            'CREATE_TIME': self.CREATE_TIME,
            'ID': self.ID,
            'CODE': self.CODE,
            'FXBGPC': self.FXBGPC,
            'TGSJ': self.TGSJ,
            'SSEJ': self.SSEJ,
            'CYDW': self.CYDW,
            'JYDS': self.JYDS,
            'SXLX': self.SXLX,
            'JYLX': self.JYLX,
            'JYBS': self.JYBS,
            'JYJE': self.JYJE,
            'FKQK': self.FKQK,
            'MZQK': self.MZQK
        }

